//
//  HomeLoanCell.swift
//  EasyDana
//
//  Created by mac on 2024/10/11.
//

import UIKit
import Kingfisher
class HomeLoanCell: UITableViewCell {

    private var _model: HomeDataModel.OrderTillyModel.StuffModel?
    
    var detailAction: ((HomeDataModel.OrderTillyModel.StuffModel?)->Void)?
    
    var model: HomeDataModel.OrderTillyModel.StuffModel? {
        get {
            return _model
        }
        set {
            _model = newValue
            self.iconView.kf.setImage(with: URL(string: newValue?.coffree ?? ""))
            self.nameLabel.text = newValue?.elegant
            self.amountLabel.text = newValue?.painted
            self.loanTermTitleLabel.text = newValue?.wed
            self.loanTermLabel.text = newValue?.terrible
            self.rateTitleLabel.text = newValue?.sent
            self.rateLabel.text = newValue?.cost
            self.applyButton.setAttributedTitle(NSAttributedString(string: newValue?.evenings ?? "", attributes: [.foregroundColor: UIColor.white, .font: UIFont(name: "Righteous-Regular", size: 16)!]), for: .normal)
//            self.applyButton.setTitle(newValue?.evenings, for: .normal)
            self.applyButton.setTitle("haha", for: .normal)
        }
    }
    
    @IBAction func loanAction(_ sender: UIButton) {
        self.detailAction?(self.model)
    }
    
    
    @IBOutlet weak var iconView: UIImageView!
    
    @IBOutlet weak var nameLabel: UILabel!
    
    @IBOutlet weak var amountLabel: UILabel!
    
    @IBOutlet weak var loanTermTitleLabel: UILabel!
    
    @IBOutlet weak var loanTermLabel: UILabel!
    
    @IBOutlet weak var rateTitleLabel: UILabel!
    
    @IBOutlet weak var rateLabel: UILabel!
    
    @IBOutlet weak var applyButton: UIButton!
    
    @IBOutlet weak var containerView: UIView!
    
    override func awakeFromNib() {
        super.awakeFromNib()
//        self.applyButton.titleLabel?.font = UIFont(name: "Righteous-Regular", size: 16)
        self.applyButton.layer.masksToBounds = true
        self.applyButton.layer.cornerRadius = 20
        self.amountLabel.font = UIFont(name: "Righteous-Regular", size: 28)
        self.containerView.layer.masksToBounds = true
        self.containerView.layer.cornerRadius = 14
        self.containerView.layer.shadowColor = UIColor.black.cgColor
        self.containerView.layer.shadowOpacity = 0.1
        self.containerView.layer.shadowRadius = 4
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
